home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6784 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: engr.sgi.com!shankar
  2. From: shankar@mti.sgi.com (Shankar Unni)
  3. Newsgroups: gnu.g++.help,comp.lang.c++,comp.sys.sgi.apps,comp.sys.sgi.misc
  4. Subject: Re: SGI and C++
  5. Followup-To: gnu.g++.help,comp.lang.c++,comp.sys.sgi.apps,comp.sys.sgi.misc
  6. Date: 19 Feb 1996 21:46:04 GMT
  7. Organization: Silicon Graphics, Inc., Mountain View, CA
  8. Distribution: world
  9. Message-ID: <4gar2s$905@fido.asd.sgi.com>
  10. References: <4f609s$rho@fu-berlin.de> <4f6726$4ch@fido.asd.sgi.com> <4fahih$s13@fu-berlin.de> <4fbhs0$eo3@fido.asd.sgi.com> <4fl2nh$b66@sun20.ccd.bnl.gov> <4ga186$bk2@oban.cc.ic.ac.uk>
  11. Reply-To: shankar@engr.sgi.com
  12. NNTP-Posting-Host: boris.mti.sgi.com
  13. X-Newsreader: TIN [version 1.2 PL2]
  14.  
  15. Thomas Sippel - Dau (vulture@imperial.ac.uk) wrote:
  16.  
  17. > Essentially that is because the gcc implementation of templates is along
  18. > the lines of "proovide the minimum necessary to get it going", while
  19. > the ATT code (on which the SGI compiler is based) used a more general
  20. > approach.
  21.  
  22. Umm, the SGI compiler is NOT ATT-based (at least, not since
  23. Irix 5.3/Irix 6.0.1).
  24.  
  25. I assume the original poster meant that the generated code ran slowly, not
  26. that the compilation itself was slower..
  27.  
  28. There *is* a known bug that I found recently (for which there won't be a fix
  29. in Irix 6.2, since we found the problem too late to get into that release - it
  30. will be fixed in a patch), where if you declare a template member function
  31. in the following way, it's NOT inlined:
  32.  
  33.   template <class T> class Foo {
  34.       ...
  35.       void memfunc();    /* no inline specification here */
  36.       ...
  37.   };
  38.  
  39.   template <class T> inline Foo<T>::memfunc()
  40.   {
  41.     /* defined as inline, but compiler will fail to inline it */
  42.   }
  43.  
  44.  
  45. The workaround for this problem is to stick the inline keyword before the
  46. declaration of the member function inside the template class.
  47.  
  48. This *may* be the reason for the slowness.  In all other respects, there
  49. should be no difference between template and non-template code.
  50. --
  51. Shankar Unni                E-Mail:    shankar@sgi.com
  52. Silicon Graphics Inc.            Phone:    +1-415-933-2072
  53. URL:    http://reality.sgi.com/employees/shankar
  54.